package com.shanyi.sendmsg.tool;

import com.alibaba.fastjson.JSONObject;
import com.shanyi.sendmsg.dto.resp.WeatherInfoRespDto;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Service
public class WeaJson2Object {

    public static WeatherInfoRespDto weaJson2Object(String json) {
        JSONObject jsonObject = JSONObject.parseObject(json);
        String dateTime = (String) jsonObject.get("date");
        String weather = (String) jsonObject.get("wea_day");
        String city = (String) jsonObject.get("city");
        String tem2 = (String) jsonObject.get("tem2");
        String tem1 = (String) jsonObject.get("tem1");
        return new WeatherInfoRespDto(dateTime, city, weather, tem1, tem2);
    }
}
